package com.controller.manage;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.po.SystemMessage;
import com.service.manage.SystemMessageService;
import com.util.UUIDGenerator;

@Controller
@RequestMapping("/jsp/manager")
public class SystemMessageController {
	@Resource(name = "systemMessageServiceImp")
	private SystemMessageService systemMessageService;
	@ResponseBody
	@RequestMapping(value = "/getSystemMessageList")
	public Map<String, Object> getSystemMessageList(SystemMessage systemMessage,Integer page,Integer rows) {
		System.out.println("page"+page+"    rows"+rows);
		systemMessage.setPage(((page-1)*rows));
		systemMessage.setRows(rows);
			
		List<SystemMessage> list=systemMessageService.getSystemMessageList(systemMessage);
		int count = systemMessageService.getSystemMessageCount(systemMessage);
		
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("rows", list);
		map.put("total", count);
		return map;
	}
	@ResponseBody
	@RequestMapping(value = "/deleteSystemMessage")
	public int deleteUser(@RequestParam("sysmess_id") String id) {
		int i=systemMessageService.deleteSystemMessage(id);
		return i;
	}
	@ResponseBody
	@RequestMapping(value="/deleteSystemMessageList")
	public int delUserList(String id){
		String[] ids =id.split(",");
		int result = systemMessageService.deleteSystemMessageList(ids);
		return result;
	}
	@ResponseBody
	@RequestMapping(value="/addSystemMessage")
	public int addUser(SystemMessage systemMessage){
		systemMessage.setSysmess_id(UUIDGenerator.getUUID());
		int result = systemMessageService.addSystemMessage(systemMessage);
		
	    return result;
	}
}
